using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpDataTypesDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            // 1. 字符串 (string)
            string str = "Hello World";
            Console.WriteLine("字符串示例：");
            Console.WriteLine($"原始字符串: {str}");
            Console.WriteLine($"转大写: {str.ToUpper()}");
            Console.WriteLine($"转小写: {str.ToLower()}");
            Console.WriteLine($"长度: {str.Length}");
            Console.WriteLine($"包含'World': {str.Contains("World")}");
            Console.WriteLine($"替换: {str.Replace("World", "C#")}");
            Console.WriteLine($"分割: {string.Join(", ", str.Split(' '))}");
            Console.WriteLine();

            // 2. 整数 (int)
            int number = 42;
            Console.WriteLine("整数示例：");
            Console.WriteLine($"原始数字: {number}");
            Console.WriteLine($"转字符串: {number.ToString()}");
            Console.WriteLine($"最大值: {int.MaxValue}");
            Console.WriteLine($"最小值: {int.MinValue}");
            Console.WriteLine($"绝对值: {Math.Abs(-number)}");
            Console.WriteLine();

            // 3. 浮点数 (double)
            double pi = 3.14159;
            Console.WriteLine("浮点数示例：");
            Console.WriteLine($"原始值: {pi}");
            Console.WriteLine($"四舍五入: {Math.Round(pi, 2)}");
            Console.WriteLine($"向上取整: {Math.Ceiling(pi)}");
            Console.WriteLine($"向下取整: {Math.Floor(pi)}");
            Console.WriteLine();

            // 4. 布尔值 (bool)
            bool isTrue = true;
            Console.WriteLine("布尔值示例：");
            Console.WriteLine($"原始值: {isTrue}");
            Console.WriteLine($"取反: {!isTrue}");
            Console.WriteLine();

            // 5. 日期时间 (DateTime)
            DateTime now = DateTime.Now;
            Console.WriteLine("日期时间示例：");
            Console.WriteLine($"当前时间: {now}");
            Console.WriteLine($"年: {now.Year}");
            Console.WriteLine($"月: {now.Month}");
            Console.WriteLine($"日: {now.Day}");
            Console.WriteLine($"格式化: {now.ToString("yyyy-MM-dd HH:mm:ss")}");
            Console.WriteLine($"添加天数: {now.AddDays(1)}");
            Console.WriteLine();

            // 6. 数组 (Array)
            int[] numbers = { 1, 2, 3, 4, 5 };
            Console.WriteLine("数组示例：");
            Console.WriteLine($"原始数组: {string.Join(", ", numbers)}");
            Console.WriteLine($"长度: {numbers.Length}");
            Console.WriteLine($"第一个元素: {numbers[0]}");
            Console.WriteLine($"最后一个元素: {numbers[numbers.Length - 1]}");
            Console.WriteLine($"排序后: {string.Join(", ", numbers.OrderBy(x => x))}");
            Console.WriteLine();

            // 7. 列表 (List<T>)
            List<string> fruits = new List<string> { "苹果", "香蕉", "橙子" };
            Console.WriteLine("列表示例：");
            Console.WriteLine($"原始列表: {string.Join(", ", fruits)}");
            fruits.Add("葡萄");
            Console.WriteLine($"添加后: {string.Join(", ", fruits)}");
            fruits.Remove("香蕉");
            Console.WriteLine($"删除后: {string.Join(", ", fruits)}");
            Console.WriteLine($"包含'苹果': {fruits.Contains("苹果")}");
            Console.WriteLine($"数量: {fruits.Count}");
            Console.WriteLine();

            // 8. 字典 (Dictionary<TKey, TValue>)
            Dictionary<string, int> ages = new Dictionary<string, int>
            {
                { "张三", 25 },
                { "李四", 30 },
                { "王五", 28 }
            };
            Console.WriteLine("字典示例：");
            Console.WriteLine("原始字典内容：");
            foreach (var pair in ages)
            {
                Console.WriteLine($"{pair.Key}: {pair.Value}岁");
            }
            ages.Add("赵六", 35);
            Console.WriteLine($"添加后赵六的年龄: {ages["赵六"]}");
            Console.WriteLine($"包含'张三': {ages.ContainsKey("张三")}");
            Console.WriteLine($"键的数量: {ages.Count}");
        }
    }
} 